package com.yili.oa.dao;

import com.yili.oa.models.ExtractsRecord;
import com.yili.oa.models.ExtractsRecordExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface ExtractsRecordMapper {
    @SelectProvider(type=ExtractsRecordSqlProvider.class, method="countByExample")
    long countByExample(ExtractsRecordExample example);

    @DeleteProvider(type=ExtractsRecordSqlProvider.class, method="deleteByExample")
    int deleteByExample(ExtractsRecordExample example);

    @Delete({
        "delete from t_extracts_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into t_extracts_record (create_time, amount, ",
        "status, user_id, detail)",
        "values (#{createTime,jdbcType=TIMESTAMP}, #{amount,jdbcType=DECIMAL}, ",
        "#{status,jdbcType=INTEGER}, #{userId,jdbcType=BIGINT}, #{detail,jdbcType=VARCHAR})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insert(ExtractsRecord record);

    @InsertProvider(type=ExtractsRecordSqlProvider.class, method="insertSelective")
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Long.class)
    int insertSelective(ExtractsRecord record);

    @SelectProvider(type=ExtractsRecordSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DECIMAL),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR)
    })
    List<ExtractsRecord> selectByExample(ExtractsRecordExample example);

    @Select({
        "select",
        "id, create_time, amount, status, user_id, detail",
        "from t_extracts_record",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="amount", property="amount", jdbcType=JdbcType.DECIMAL),
        @Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
        @Result(column="user_id", property="userId", jdbcType=JdbcType.BIGINT),
        @Result(column="detail", property="detail", jdbcType=JdbcType.VARCHAR)
    })
    ExtractsRecord selectByPrimaryKey(Long id);

    @UpdateProvider(type=ExtractsRecordSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") ExtractsRecord record, @Param("example") ExtractsRecordExample example);

    @UpdateProvider(type=ExtractsRecordSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") ExtractsRecord record, @Param("example") ExtractsRecordExample example);

    @UpdateProvider(type=ExtractsRecordSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ExtractsRecord record);

    @Update({
        "update t_extracts_record",
        "set create_time = #{createTime,jdbcType=TIMESTAMP},",
          "amount = #{amount,jdbcType=DECIMAL},",
          "status = #{status,jdbcType=INTEGER},",
          "user_id = #{userId,jdbcType=BIGINT},",
          "detail = #{detail,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(ExtractsRecord record);
}